home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / linux / atari / source / source.lzh / atari-linux-0.01pl3 / drivers / block / genhd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  2.4 KB  |  107 lines

  1. /*
  2.  *  Code extracted from
  3.  *  linux/kernel/hd.c
  4.  *
  5.  *  Copyright (C) 1991, 1992  Linus Torvalds
  6.  */
  7.  
  8. /*
  9.  *  Thanks to Branko Lankester, lankeste@fwi.uva.nl, who found a bug
  10.  *  in the early extended-partition checks and added DM partitions
  11.  */
  12.  
  13. #include <linux/config.h>
  14. #include <linux/fs.h>
  15. #include <linux/genhd.h>
  16. #include <linux/kernel.h>
  17.  
  18. struct gendisk *gendisk_head = NULL;
  19.  
  20. int current_minor = 0;
  21. extern int *blk_size[];
  22. extern void rd_load(void);
  23. extern int ramdisk_size;
  24.  
  25. static void check_partition(struct gendisk *hd, unsigned int dev)
  26. {
  27.     static int first_time = 1;
  28.  
  29.     if (first_time)
  30.         printk("Partition check:\n");
  31.     first_time = 0;
  32.  
  33.     mach_check_partition (hd, dev);
  34. }
  35.  
  36. /* This function is used to re-read partition tables for removable disks.
  37.    Much of the cleanup from the old partition tables should have already been
  38.    done */
  39.  
  40. /* This function will re-read the partition tables for a given device,
  41. and set things back up again.  There are some important caveats,
  42. however.  You must ensure that no one is using the device, and no one
  43. can start using the device while this function is being executed. */
  44.  
  45. void resetup_one_dev(struct gendisk *dev, int drive)
  46. {
  47.     int i;
  48.     int start = drive<<dev->minor_shift;
  49.     int j = start + dev->max_p;
  50.     int major = dev->major << 8;
  51.  
  52.     current_minor = 1+(drive<<dev->minor_shift);
  53.     check_partition(dev, major+(drive<<dev->minor_shift));
  54.  
  55.     for (i=start ; i < j ; i++)
  56.         dev->sizes[i] = dev->part[i].nr_sects >> (BLOCK_SIZE_BITS - 9);
  57. }
  58.  
  59. static void setup_dev(struct gendisk *dev)
  60. {
  61.     int i;
  62.     int j = dev->max_nr * dev->max_p;
  63.     int major = dev->major << 8;
  64.     int drive;
  65.  
  66.  
  67.     for (i = 0 ; i < j; i++)  {
  68.         dev->part[i].start_sect = 0;
  69.         dev->part[i].nr_sects = 0;
  70.     }
  71.     dev->init();
  72.     for (drive=0 ; drive<dev->nr_real ; drive++) {
  73.         current_minor = 1+(drive<<dev->minor_shift);
  74.         check_partition(dev, major+(drive<<dev->minor_shift));
  75.     }
  76.     for (i=0 ; i < j ; i++)
  77.         dev->sizes[i] = dev->part[i].nr_sects >> (BLOCK_SIZE_BITS - 9);
  78.     blk_size[dev->major] = dev->sizes;
  79. }
  80.  
  81. /* This may be used only once, enforced by 'static int callable' */
  82. asmlinkage int sys_setup(void * BIOS)
  83. {
  84.     static int callable = 1;
  85.     struct gendisk *p;
  86.     int nr=0;
  87.  
  88. #ifdef DEBUG
  89.     printk ("sys_setup: press mousebutton to continue\n");
  90.     waitbut();
  91. #endif
  92.  
  93.     if (!callable)
  94.         return -1;
  95.     callable = 0;
  96.  
  97.     for (p = gendisk_head ; p ; p=p->next) {
  98.         setup_dev(p);
  99.         nr += p->nr_real;
  100.     }
  101.     if (ramdisk_size)
  102.         rd_load();
  103.  
  104.     mount_root();
  105.     return (0);
  106. }
  107.